package com.ronsai.umtrack.presenter;

import android.content.Context;

import com.ronsai.umtrack.api.ObserverResponseListener;
import com.ronsai.umtrack.contract.HomeContract;
import com.ronsai.umtrack.entity.Banner;
import com.ronsai.umtrack.model.HomeModel;
import com.ronsai.umtrack.util.ToastUtil;

import java.util.List;

public class HomePresenter extends HomeContract.Presenter {

    private Context mContext;
    private HomeModel homeModel;

    public HomePresenter(Context context) {
        mContext = context;
        homeModel = new HomeModel();
    }

    @Override
    public void getHomeBannerList() {
        homeModel.getHomeBannerList(mContext, new ObserverResponseListener<List<Banner>>() {
            @Override
            public void onSuccess(List<Banner> list) {
                if (getView() != null) {
                    getView().getBannerSuccess(list);
                }
            }

            @Override
            public void onError(int code, String msg) {
                ToastUtil.showShortToast(msg);
            }
        });
    }
}
